package com.xin.xinapiinterface.controller;

import com.xin.apicommon.model.entity.User;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;


//服务端

@RestController
@RequestMapping("/name")
public class NameController {


    

    //因为客户端将信息放在了请求头中，所以这里引入了HttpServletRequest参数
    @PostMapping("/user")
    public String getNameByPostWithJson(@RequestBody User user, HttpServletRequest request) throws UnsupportedEncodingException {
        return "发送POST请求 JSON中你的名字是：" + user.getUserName();
    }

}
